package com.zyb.lmbackend.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * DashScope Agent configuration.
 *
 * Supports two agents (taxonomy/classify). For backward compatibility,
 * the legacy path spring.ai.dashscope.agent.* can still be used: when a specific
 * agent is not configured, the legacy "agent" config will be applied.
 *
 * Example YAML:
 *   spring.ai.dashscope:
 *     taxonomy:
 *       agent:
 *         api-key: ${AI_API_KEY}
 *         app-id: ${DASHSCOPE_TAX_APP_ID}
 *         model: qwen-2.5-max
 *         temperature: 0.1
 *     classify:
 *       agent:
 *         api-key: ${AI_API_KEY}
 *         app-id: ${DASHSCOPE_CLS_APP_ID}
 *         model: qwen-2.5-plus
 *         temperature: 0.0
 *     agent:
 *       api-key: ${AI_API_KEY}
 *       app-id: ${DASHSCOPE_APP_ID}
 *       model: qwen-2.5-plus
 */
/**
 * DashScope 模型调用配置（支持 taxonomy/classify 两套）
 */
@Configuration
@ConfigurationProperties(prefix = "spring.ai.dashscope")
@Data
public class AiProperties {

    @Data
    /** 单个调用端配置：API Key、AppID/模型名、温度与超时等。 */
    public static class AgentCfg {
        private String apiKey;
        private String appId;
        private String model;
        private Double temperature;
        private String timeout;
    }

    // New preferred layout
    private AgentCfg taxonomy;
    private AgentCfg classify;

    // Backward compatible single-agent config (spring.ai.dashscope.agent.*)
    private AgentCfg agent;

    public AgentCfg taxonomyCfg() {
        return taxonomy != null ? taxonomy : agent;
    }

    public AgentCfg classifyCfg() {
        return classify != null ? classify : agent;
    }
}
